package com.itheima.controller;

import com.itheima.domain.db.User;
import com.itheima.service.db.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/save")
    public Long save(@RequestBody User user){
        return userService.save(user);
    }

    @GetMapping("/findByPhone")
    public User findByPhone(String phone) {
        return userService.findByPhone(phone);
    }

    @GetMapping("/findUserById")
    public User findUserById(Long userId) {
        return userService.findUserById(userId);
    }

    @PutMapping("/updatePhone")
    public void updatePhone(String phone,Long id) {
        userService.updatePhone(phone,id);
    }


}
